
const data = {
	contract: '',
	AskPrice: 0,
	AskVolume: 0,
	BidPrice: 0,
	BidVolume: 0,
	LastPrice: 0,
	Time: Date.now()
}

async function main(market, base, quote) {
	const random = 1 + parseInt(Math.random() * 98)
	let url = ''
	if (base == 'mtc' && quote == 'usdt') {
		url = `https://www.coinw.me/kline/fulldepth.html?symbol=42&step=60&rand=${random}`
	}
	if (!url) return
	try {
		const {statusCode, body} = await Request.getAsync(url)
		console.log(url, statusCode)

		if (statusCode == 200) {
			let datas = JSON.parse(body)
			const {bids, asks} = datas.depth
			data[1] = asks[0][0] / config.usdt_cny_rate
			data[2] = bids[0][0] / config.usdt_cny_rate
			Cache.hmset('data', data)
		}
	} catch (error) {
		LOG([market, error.code || error.message || error])
	}
	
	await Promise.delay(config.timeout * 0.5)
	main(market, base, quote)
}

module.exports = main
